// "use strict"

// //文档：https://help.aliyun.com/document_detail/101414.html?spm=a2c4g.11186623.6.616.21e47535m8W3bi
// //错误码：https://help.aliyun.com/document_detail/101346.html?spm=a2c4g.11186623.2.14.d0c256e0bTwBLj
// //安装： npm install @alicloud/pop-core -S

// const url = 'https://dysmsapi.aliyuncs.com';

// exports.format = {
//     "id":'alisms',
//     "name":"阿里云短信服务（Short Message Service）",
//     "fields":{
//         "appid" :{'type':'string','val':'','name':"accessKeyId"},
//         "secret" :{'type':'string','val':'','name':"accessKeySecret"},
//         "expire" :{'type':'int','val':0,'name':"验证码超时(S)"},
//         "SignName" :{'type':'string','val':'','name':"SignName"},
//         "TemplateCode" :{'type':'string','val':'','name':"TemplateCode"},
//     }
// };



// //发送验证码
// exports.code = function(phone){
//     if(!this.opensdk.setting || !this.opensdk.setting.appid || !this.opensdk.setting.secret){
//         return this.error("opensdk.setting empty");
//     }


//     let Core = require('@alicloud/pop-core');

//     let code = Math.roll(1000,9999);

//     let client = new Core({
//         accessKeyId: this.opensdk.setting.appid,
//         accessKeySecret: this.opensdk.setting.secret,
//         endpoint: url,
//         apiVersion: '2017-05-25'
//     });

//     let params = {
//         "PhoneNumbers": phone,
//         "SignName": this.opensdk.setting.SignName,
//         "TemplateCode": this.opensdk.setting.TemplateCode,
//         "TemplateParam": JSON.stringify({"code":String(code)}),
//     }

//     let requestOption = {
//         method: 'POST'
//     };

//     return client.request('SendSms', params, requestOption).then((ret)=>{
//         if(!ret['Code'] || ret['Code'] !== 'OK' ){
//             return this.error(ret['Code'],ret['Message'])
//         }
//         else {
//             return {"code":code,"expire": this.opensdk.setting.expire * 1000 + Date.now() };
//         }
//     })

// }

